home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Programming / Programming Languages / Harvest C / MPW Int & Lib / Interfaces / Perf.h < prev    next >
Text File  |  1991-04-17  |  3KB  |  96 lines

  1. /************************************************************
  2.  
  3. Created: Thursday, September 7, 1989 at 9:15 PM
  4.     Perf.h
  5.     C Interface to the Macintosh Libraries
  6.  
  7.  
  8.     Copyright Apple Computer, Inc.    1986-1989
  9.     All rights reserved
  10.     
  11.     DESCRIPTION
  12.     Provides for PC-sampling of User code resources, ROM code, and RAM (misses).
  13.     Produces output text file suitable for input to PerformReport.
  14.     
  15.     Design objectives:
  16.     Language independent, i.e. works with Pascal, C, and Assembly.
  17.     Covers user resources as well as ROM code.
  18.     Memory model independent, i.e. works for Desk Accessories and drivers.
  19.     Uses TimeManager on new ROMs, Vertical Blanking interrupt on 64 K ROMs.
  20.     
  21.  
  22. ************************************************************/
  23.  
  24.  
  25. #ifndef __PERF__
  26. #define __PERF__
  27.  
  28. #ifndef __TYPES__
  29. #include <Types.h>
  30. #endif
  31.  
  32. struct TPerfGlobals {
  33.     long startROM;                /*ROM Base*/
  34.     long romHits;                /*used if MeasureROM is false*/
  35.     long misses;                /*count of PC values outside measured memory*/
  36.     long (*segArray)[1];        /*array of segment handles*/
  37.     long (*sizeArray)[1];        /*array of segment sizes*/
  38.     short (**idArray)[1];        /*array of segment rsrc IDs*/
  39.     long (*baseArray)[1];        /*array of offsets to counters for each segment*/
  40.     long (*samples)[1];         /*samples buffer*/
  41.     long buffSize;                /*size of samples buffer in bytes*/
  42.     short timeInterval;         /*number of clock intervals between interrupts*/
  43.     short bucketSize;            /*size of buckets power of 2*/
  44.     short log2buckSize;         /*used in CvtPC*/
  45.     short pcOffset;             /*offset to the user PC at interrupt time.*/
  46.     short numMeasure;            /*# Code segments (w/o jump table)- ROM etc.*/
  47.     short firstCode;            /*index of first Code segment*/
  48.     Boolean takingSamples;        /*true if sampling is enabled.*/
  49.     Boolean measureROM;
  50.     Boolean measureCode;
  51.     short ramSeg;                /*index of "segment" record to cover RAM > 0 if RAM (misses) are to be bucketed.*/
  52.     long ramBase;                /*beginning of RAM being measured.*/
  53.     short measureRAMbucketSize;
  54.     short measureRAMlog2buckSize;
  55.     short romVersion;
  56.     short vRefNum;                /*Volume where the report file is to be created*/
  57.     Boolean volumeSelected;     /*True if user selects the report file name*/
  58.     Str255 rptFileName;         /*Report file name*/
  59.     Str255 rptFileCreator;        /*Report File Creator*/
  60.     Str255 rptFileType;         /*Report File type*/
  61.     ResType getResType;         /*Resource type*/
  62. };
  63.  
  64. typedef struct TPerfGlobals TPerfGlobals;
  65. typedef TPerfGlobals *TP2PerfGlobals;
  66.  
  67. /* PerfGlobals are declared as a record, so main program can allocate
  68. as globals, desk accessory can add to globals allocated via pointer,
  69. print driver can allocate via low memory, etc. */
  70.  
  71.  
  72.  
  73. #ifdef __cplusplus
  74. extern "C" {
  75. #endif
  76. pascal Boolean InitPerf(TP2PerfGlobals *thePerfGlobals,short timerCount,
  77.     short codeAndROMBucketSize,Boolean doROM,Boolean doAppCode,const Str255 appCodeType,
  78.     short romID,const Str255 romName,Boolean doRAM,long ramLow,long ramHigh,
  79.     short ramBucketSize);                                /* called once to setup Performance monitoring
  80.  */
  81. pascal void TermPerf(TP2PerfGlobals thePerfGlobals);    /* if InitPerf succeeds then TermPerf must be called before terminating program.
  82.  */
  83. pascal Boolean PerfControl(TP2PerfGlobals thePerfGlobals,Boolean turnOn);
  84. /*
  85.     Call this to turn off/on measuring.
  86.      Returns previous state.
  87. */
  88.  
  89. pascal short PerfDump(TP2PerfGlobals thePerfGlobals,const Str255 reportFile,
  90.     Boolean doHistogram,short rptFileColumns);            /* Call this to dump the statistics into a file. */
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94.  
  95. #endif
  96.